package view;

import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import controller.Controller;

public class LoginPanel extends JFrame{
	private Controller controller;
	private JTextField user;
	private JTextField password;
	public LoginPanel() {
		this.controller = new Controller();
		this.controller.setLoginPanel(this);
		JLabel label1 = new JLabel("用户名");
		JLabel label2 = new JLabel("密码");
		JLabel label3 = new JLabel("欢迎登录20级信管6班通讯录");
		Font font = new Font("微软雅黑", Font.BOLD, 20);
		label3.setFont(font);
		label3.setForeground(Color.ORANGE);
	    user = new JTextField(10);
		password = new JTextField(10);
		JButton button1 = new JButton("登录");
		JButton button2 = new JButton("注册");
		JPanel panel3 = new JPanel();
		JPanel panel1= new JPanel();
		JPanel panel2= new JPanel();
		JPanel panel4= new JPanel();
		panel1.add(label1);
		panel2.add(label2);
		panel1.add(user);
		panel2.add(password);
		panel3.add(button1);
		panel3.add(button2);
		panel4.add(label3);
		this.add(panel4);
		this.add(panel1);
		this.add(panel2);
		this.add(panel3);
		button1.addActionListener(controller);
		button2.addActionListener(controller);
		button1.setActionCommand("login");
		button2.setActionCommand("register");
		this.setLayout(new GridLayout(5,1));
		this.setVisible(true);
		this.setSize(500, 400);
		this.setResizable(true);//可以调整窗口大小
		this.setLocationRelativeTo(null);//将窗口放在屏幕正中心
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.validate();
	}
	public JTextField getUser() {
		return user;
	}
	public void setUser(JTextField user) {
		this.user = user;
	}
	public JTextField getPassword() {
		return password;
	}
	public void setPassword(JTextField password) {
		this.password = password;
	}
	public Controller getController() {
		return controller;
	}

	
}
